<script>
import * as echarts from 'echarts'

export default {
  name: 'PieChart',
  methods: {
    initEcharts() {
      const myChart = echarts.init(document.querySelector('.chart'))
      myChart.setOption({
        legend: {
          top: 'bottom'
        },
        toolbox: {
          show: true,
          feature: {
            mark: { show: true },
            dataView: { show: true, readOnly: false },
            restore: { show: true },
            saveAsImage: { show: true }
          }
        },
        series: [
          {
            name: 'Nightingale Chart',
            type: 'pie',
            radius: [75, 80],
            center: ['50%', '50%'],
            roseType: 'area',
            itemStyle: {
              borderRadius: 8
            },
            data: [
              { value: 40, name: '员工数量' },
              { value: 38, name: '车辆数量' },
              { value: 32, name: '机构数量' },
              { value: 30, name: '运费单价' },
              { value: 28, name: '日结费用' },
              { value: 26, name: '线路数量' },
              { value: 22, name: '任务数量' },
              { value: 18, name: '作业范围' }
            ]
          }
        ]
      })
    }
  },
  mounted() {
    this.initEcharts()
  }
}
</script>

<template>
  <div class="pie-chart-container">
    <el-card shadow="never">
      <div class="chart"></div>
    </el-card>
  </div>
</template>

<style scoped lang="scss">
.pie-chart-container {
  width: 100%;
  height: 350px;

  .el-card {
    width: 100%;
    height: 350px;

    .chart {
      width: 100%;
      height: 350px;
    }
  }
}
</style>
